# -*- coding: utf-8 -*-
import scrapy


class GiteeSpider(scrapy.Spider):
    name = 'gitee'
    allowed_domains = ['gitee.com']
    start_urls = ['https://gitee.com/dbsgw/dashboard/projects']

    def start_requests(self):
        url = self.start_urls[0]
        temp = 'user_locale=zh-CN; oschina_new_user=false; visit-gitee-=1; remote_way=http; tz=Asia%2FShanghai; Hm_lvt_24f17767262929947cc3631f99bfd274=1595125792,1595333648,1595338402,1595662862; Hm_lpvt_24f17767262929947cc3631f99bfd274=1595662931; gitee-session-n=anFvMXR5YlQ0dS9EYjhXcGc1Y082ZkQ2c0hraEc0ODlHTFlmV3Uzb3hxeE93REN2R25JT3NTY290eVNWT2JqWHNBMU1BKzIwOGNBMGdkNDV0WkRGZExFemt0RlVDL1A3YUlESkY4QXE0anFQSlpWOXQxOTBCNjdsKzJxZVhnR0dPR2FxSlRqY1lnekFhVXArRVNXbHlDSlE1UzZGc1BTMTNFRUhReWNNWnkvQlpOSTJBek4wcmZITnJjbmg2elNZc3JQOUtHMmJpRGxTY0JjMzVLYzFrVks3OU9uMHdDSkxEWGY3M0RKbHROU2lUREJsOVVGK2FtUTRTdnRWc283TmZ1OWswUHgrdHV1VFI0Rnk5bnd3MFV3djJ2TVJneTBzMXozRytic1kvYW5od250bVFjRnVWWGJOTDhrVjVCbTk3MUpCWmdQYTk1QnNYRHZuVTNmdjdINHVyVkRIczN1YUdpcnJreXRNcHZZPS0tNktGSnArN1hBSEF1bDRldWZKb3Q0Zz09--9179c01f77fcad72cd31128aecd180d44d4d562d'
        cookies = {data.split('=')[0]: data.split('=')[-1] for data in temp.split("; ")}
        yield scrapy.Request(
            url=url,
            callback=self.parse,
            cookies=cookies
        )

    def parse(self, response):
        print(response.xpath('//*[@id="rc-users__container"]/div[1]/div[2]/div/div[1]/div[1]/div[1]/div[1]/strong/a/text()').get())
